package club.hicode.daydayup.feign.provider;

import club.hicode.daydayup.feign.vo.StudentVo;
import cn.hutool.core.util.RandomUtil;
import com.github.jsonzou.jmockdata.JMockData;
import com.github.jsonzou.jmockdata.TypeReference;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 学生的提供
 *
 * @author Liu Chunfu
 * @date 2018-07-05 下午3:45
 **/
@RequestMapping("/stu")
@RestController
public class StuProvider {

    @GetMapping
    public StudentVo getBook(@RequestParam("id") String id) {
        System.out.println("id is " + id);
        return JMockData.mock(StudentVo.class);
    }

    @DeleteMapping
    public StudentVo del(@RequestBody String id) {
        System.out.println("id is " + id);
        return JMockData.mock(StudentVo.class);
    }

    @PostMapping
    public StudentVo postBook(@RequestBody StudentVo bookVo) {
        System.out.println(bookVo.toString());
        return bookVo;
    }

    @PostMapping("/map")
    public Map<String, StudentVo> postBook(@RequestBody List<StudentVo> bookVo) {
        System.out.println(bookVo.toString());
        return JMockData.mock(new TypeReference<Map<String, StudentVo>>() {
        });
    }

}
